﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using C1.Win.C1Chart3D;

namespace LED_Tester
{
    public partial class frmL3 : Form
    {
        public frmL3()
        {
            InitializeComponent();
        }

        #region 变量声明

        private double gammaSample;
        private double gammaRange;
        private double thetaDegree;
        private double[] luxData;

        public double GammaSample
        {
            get { return gammaSample; }
            set { gammaSample = value; }
        }
        public double GammaRange
        {
            get { return gammaRange; }
            set { gammaRange = value; }
        }
        public double ThetaDegree
        {
            get { return thetaDegree; }
            set { thetaDegree = value; }
        }
        public double[] LuxData
        {
            get { return luxData; }
            set { luxData = value; }
        }

        public Color[] lineColor = new Color[12] { Color.Red, Color.Green, Color.Blue, Color.Purple, Color.OrangeRed, Color.Aqua, Color.Yellow, Color.RoyalBlue, Color.RosyBrown, Color.Violet, Color.Sienna, Color.Firebrick };
        Chart3DDataSetPoint dataSetPoint = new Chart3DDataSetPoint();

        Chart3DPoint[] axisX1Point;
        Chart3DPointSeries axisX1Series;
        Chart3DPoint[] axisX2Point;
        Chart3DPointSeries axisX2Series;
        Chart3DPoint[] axisX3Point;
        Chart3DPointSeries axisX3Series;

        Chart3DPoint[] axisY1Point;
        Chart3DPointSeries axisY1Series;
        Chart3DPoint[] axisY2Point;
        Chart3DPointSeries axisY2Series;
        Chart3DPoint[] axisY3Point;
        Chart3DPointSeries axisY3Series;

        Chart3DPoint[] axisZ1Point;
        Chart3DPointSeries axisZ1Series;
        Chart3DPoint[] axisZ2Point;
        Chart3DPointSeries axisZ2Series;
        Chart3DPoint[] axisZ3Point;
        Chart3DPointSeries axisZ3Series;

        #endregion

        #region 功能函数
        // 设置线数目
        void setZoneNumber(int num)
        {
            chart3D.ChartGroups[0].Contour.NumLevels = num;
        }
        // 设置颜色
        void setZoneChart(C1.Win.C1Chart3D.ColorSetEnum clrset)
        {
            if (!chart3D.ChartGroups[0].Contour.IsZoned)
                chart3D.ChartGroups[0].Contour.IsZoned = true;
            chart3D.ChartGroups.ContourStyles.ColorSet = clrset;
        }

        private void initialize()
        {
            dataSetPoint.SeriesCollection.Clear();
            //设置坐标轴刻度//调节视距
            this.chart3D.ChartArea.AxisX.AutoMajor = true;
            this.chart3D.ChartArea.AxisX.AutoMinor = true;
            this.chart3D.ChartArea.AxisX.Min = -1000;
            this.chart3D.ChartArea.AxisX.Max = 1000;
            this.chart3D.ChartArea.AxisY.AutoMajor = true;
            this.chart3D.ChartArea.AxisY.AutoMinor = true;
            this.chart3D.ChartArea.AxisY.Min = -1000;
            this.chart3D.ChartArea.AxisY.Max = 1000;
            this.chart3D.ChartArea.AxisZ.AutoMajor = true;
            this.chart3D.ChartArea.AxisZ.AutoMinor = true;
            this.chart3D.ChartArea.AxisZ.Min = 0;
            this.chart3D.ChartArea.AxisZ.Max = 2000;
            //隐藏坐标轴
            this.chart3D.ChartArea.AxisX.Visible = false;
            this.chart3D.ChartArea.AxisY.Visible = false;
            this.chart3D.ChartArea.AxisZ.Visible = false;

            #region 自定义坐标轴

            axisX1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX1Point[0].X = 0;
            axisX1Point[0].Y = 0;
            axisX1Point[0].Z = 0;
            axisX1Point[1].X = 800;
            axisX1Point[1].Y = 0;
            axisX1Point[1].Z = 0;

            axisX1Series = new Chart3DPointSeries();
            axisX1Series.Points = axisX1Point;

            axisX2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX2Point[0].X = 795f;
            axisX2Point[0].Y = 5f;
            axisX2Point[0].Z = 0;
            axisX2Point[1].X = 800;
            axisX2Point[1].Y = 0;
            axisX2Point[1].Z = 0;
            axisX2Series = new Chart3DPointSeries();
            axisX2Series.Points = axisX2Point;

            axisX3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX3Point[0].X = 795f;
            axisX3Point[0].Y = -5f;
            axisX3Point[0].Z = 0;
            axisX3Point[1].X = 800;
            axisX3Point[1].Y = 0;
            axisX3Point[1].Z = 0;
            axisX3Series = new Chart3DPointSeries();
            axisX3Series.Points = axisX3Point;

            dataSetPoint.SeriesCollection.Add(axisX1Series);
            dataSetPoint.SeriesCollection.Add(axisX2Series);
            dataSetPoint.SeriesCollection.Add(axisX3Series);

            dataSetPoint.SeriesCollection[0].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[0].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[0].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[0].Connected = true;
            dataSetPoint.SeriesCollection[0].Style.SymbolStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[1].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[1].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[1].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[1].Connected = true;
            dataSetPoint.SeriesCollection[1].Style.SymbolStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[2].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[2].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[2].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[2].Connected = true;
            dataSetPoint.SeriesCollection[2].Style.SymbolStyle.Color = Color.Red;



            axisY1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY1Point[0].X = 0;
            axisY1Point[0].Y = 0;
            axisY1Point[0].Z = 0;
            axisY1Point[1].X = 0;
            axisY1Point[1].Y = 800;
            axisY1Point[1].Z = 0;

            axisY1Series = new Chart3DPointSeries();
            axisY1Series.Points = axisY1Point;

            axisY2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY2Point[0].X = 5f;
            axisY2Point[0].Y = 795f;
            axisY2Point[0].Z = 0;
            axisY2Point[1].X = 0;
            axisY2Point[1].Y = 800;
            axisY2Point[1].Z = 0;
            axisY2Series = new Chart3DPointSeries();
            axisY2Series.Points = axisY2Point;

            axisY3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY3Point[0].X = -05f;
            axisY3Point[0].Y = 795f;
            axisY3Point[0].Z = 0;
            axisY3Point[1].X = 0;
            axisY3Point[1].Y = 800;
            axisY3Point[1].Z = 0;
            axisY3Series = new Chart3DPointSeries();
            axisY3Series.Points = axisY3Point;


            dataSetPoint.SeriesCollection.Add(axisY1Series);
            dataSetPoint.SeriesCollection.Add(axisY2Series);
            dataSetPoint.SeriesCollection.Add(axisY3Series);

            dataSetPoint.SeriesCollection[3].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[3].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[3].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[3].Connected = true;
            dataSetPoint.SeriesCollection[3].Style.SymbolStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[4].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[4].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[4].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[4].Connected = true;
            dataSetPoint.SeriesCollection[4].Style.SymbolStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[5].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[5].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[5].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[5].Connected = true;
            dataSetPoint.SeriesCollection[5].Style.SymbolStyle.Color = Color.Green;


            axisZ1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ1Point[0].X = 0;
            axisZ1Point[0].Y = 0;
            axisZ1Point[0].Z = 0;
            axisZ1Point[1].X = 0;
            axisZ1Point[1].Y = 0;
            axisZ1Point[1].Z = 1600;

            axisZ1Series = new Chart3DPointSeries();
            axisZ1Series.Points = axisZ1Point;

            axisZ2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ2Point[0].X = 05f;
            axisZ2Point[0].Y = 0;
            axisZ2Point[0].Z = 1595f;
            axisZ2Point[1].X = 0;
            axisZ2Point[1].Y = 0;
            axisZ2Point[1].Z = 1600;
            axisZ2Series = new Chart3DPointSeries();
            axisZ2Series.Points = axisZ2Point;

            axisZ3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ3Point[0].X = -05f;
            axisZ3Point[0].Y = 0;
            axisZ3Point[0].Z = 1595f;
            axisZ3Point[1].X = 0;
            axisZ3Point[1].Y = 0;
            axisZ3Point[1].Z = 1600;
            axisZ3Series = new Chart3DPointSeries();
            axisZ3Series.Points = axisZ3Point;

            dataSetPoint.SeriesCollection.Add(axisZ1Series);
            dataSetPoint.SeriesCollection.Add(axisZ2Series);
            dataSetPoint.SeriesCollection.Add(axisZ3Series);

            dataSetPoint.SeriesCollection[6].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[6].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[6].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[6].Connected = true;
            dataSetPoint.SeriesCollection[6].Style.SymbolStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[7].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[7].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[7].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[7].Connected = true;
            dataSetPoint.SeriesCollection[7].Style.SymbolStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[8].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[8].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[8].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[8].Connected = true;
            dataSetPoint.SeriesCollection[8].Style.SymbolStyle.Color = Color.Blue;

            #endregion

            setZoneNumber(500);
            setZoneChart((C1.Win.C1Chart3D.ColorSetEnum)2);
            chart3D.ChartGroups[0].ChartData.Set = dataSetPoint;

            dataInit();
        }

        private void dataInit()
        {
            Chart3DPoint[] pot = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot1 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot2 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot3 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot4 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot5 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot6 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot7 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot8 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot9 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot10 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot11 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            pot[0] = new Chart3DPoint(0, 0, 0);
            pot1[0] = new Chart3DPoint(0, 0, 0);
            pot2[0] = new Chart3DPoint(0, 0, 0);
            pot3[0] = new Chart3DPoint(0, 0, 0);
            pot4[0] = new Chart3DPoint(0, 0, 0);
            pot5[0] = new Chart3DPoint(0, 0, 0);
            pot6[0] = new Chart3DPoint(0, 0, 0);
            pot7[0] = new Chart3DPoint(0, 0, 0);
            pot8[0] = new Chart3DPoint(0, 0, 0);
            pot9[0] = new Chart3DPoint(0, 0, 0);
            pot10[0] = new Chart3DPoint(0, 0, 0);
            pot11[0] = new Chart3DPoint(0, 0, 0);
            Chart3DPointSeries ps = new Chart3DPointSeries();
            Chart3DPointSeries ps1 = new Chart3DPointSeries();
            Chart3DPointSeries ps2 = new Chart3DPointSeries();
            Chart3DPointSeries ps3 = new Chart3DPointSeries();
            Chart3DPointSeries ps4 = new Chart3DPointSeries();
            Chart3DPointSeries ps5 = new Chart3DPointSeries();
            Chart3DPointSeries ps6 = new Chart3DPointSeries();
            Chart3DPointSeries ps7 = new Chart3DPointSeries();
            Chart3DPointSeries ps8 = new Chart3DPointSeries();
            Chart3DPointSeries ps9 = new Chart3DPointSeries();
            Chart3DPointSeries ps10 = new Chart3DPointSeries();
            Chart3DPointSeries ps11 = new Chart3DPointSeries();
            ps.Points = pot;
            ps1.Points = pot1;
            ps2.Points = pot2;
            ps3.Points = pot3;
            ps4.Points = pot4;
            ps5.Points = pot5;
            ps6.Points = pot6;
            ps7.Points = pot7;
            ps8.Points = pot8;
            ps9.Points = pot9;
            ps10.Points = pot10;
            ps11.Points = pot11;
            dataSetPoint.SeriesCollection.Add(ps);
            dataSetPoint.SeriesCollection.Add(ps1);
            dataSetPoint.SeriesCollection.Add(ps2);
            dataSetPoint.SeriesCollection.Add(ps3);
            dataSetPoint.SeriesCollection.Add(ps4);
            dataSetPoint.SeriesCollection.Add(ps5);
            dataSetPoint.SeriesCollection.Add(ps6);
            dataSetPoint.SeriesCollection.Add(ps7);
            dataSetPoint.SeriesCollection.Add(ps8);
            dataSetPoint.SeriesCollection.Add(ps9);
            dataSetPoint.SeriesCollection.Add(ps10);
            dataSetPoint.SeriesCollection.Add(ps11);
            dataSetPoint.SeriesCollection[9].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[9].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[9].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[9].Connected = true;
            dataSetPoint.SeriesCollection[10].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[10].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[10].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[10].Connected = true;
            dataSetPoint.SeriesCollection[11].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[11].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[11].Style.LineStyle.Color = Color.Brown;
            dataSetPoint.SeriesCollection[11].Connected = true;
            dataSetPoint.SeriesCollection[12].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[12].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[12].Style.LineStyle.Color = Color.Cornsilk;
            dataSetPoint.SeriesCollection[12].Connected = true;
            dataSetPoint.SeriesCollection[13].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[13].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[13].Style.LineStyle.Color = Color.DarkGoldenrod;
            dataSetPoint.SeriesCollection[13].Connected = true;
            dataSetPoint.SeriesCollection[14].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[14].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[14].Style.LineStyle.Color = Color.DarkRed;
            dataSetPoint.SeriesCollection[14].Connected = true;
            dataSetPoint.SeriesCollection[15].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[15].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[15].Style.LineStyle.Color = Color.DeepPink;
            dataSetPoint.SeriesCollection[15].Connected = true;
            dataSetPoint.SeriesCollection[16].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[16].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[16].Style.LineStyle.Color = Color.FloralWhite;
            dataSetPoint.SeriesCollection[16].Connected = true;
            dataSetPoint.SeriesCollection[17].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[17].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[17].Style.LineStyle.Color = Color.GhostWhite;
            dataSetPoint.SeriesCollection[17].Connected = true;
            dataSetPoint.SeriesCollection[18].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[18].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[18].Style.LineStyle.Color = Color.Goldenrod;
            dataSetPoint.SeriesCollection[18].Connected = true;
            dataSetPoint.SeriesCollection[19].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[19].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[19].Style.LineStyle.Color = Color.LemonChiffon;
            dataSetPoint.SeriesCollection[19].Connected = true;
            dataSetPoint.SeriesCollection[20].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[20].Style.SymbolStyle.Size = 1;
            dataSetPoint.SeriesCollection[20].Style.LineStyle.Color = Color.MediumPurple;
            dataSetPoint.SeriesCollection[20].Connected = true;
        }

        public void Display()
        {

            int length = luxData.Length;
            double r = 0;

            //Chart3DPoint[] lux3DPoint = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), length + 2);
            Chart3DPoint[] lux3DPoint = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), length);
            //lux3DPoint[0].X = 0;
            //lux3DPoint[0].Y = 0;
            //lux3DPoint[0].Z = 0;

            double max = 0;
            double temp = 0;
            for (int i = 0; i < length; i++)
            {
                r = i * gammaSample - gammaRange;
                lux3DPoint[i].X = luxData[i] / 10 * System.Math.Sin(r * 3.14159f / 180f) * System.Math.Cos(thetaDegree * 3.14159f / 180f);
                lux3DPoint[i].Y = luxData[i] / 10 * System.Math.Sin(r * 3.14159f / 180f) * System.Math.Sin(thetaDegree * 3.14159f / 180f);
                lux3DPoint[i].Z = luxData[i] / 10 * System.Math.Cos(r * 3.14159f / 180f);
                temp = lux3DPoint[i].Z;
                if (temp > max)
                    max = temp;
            }

            double line = max * 0.03;
            //lux3DPoint[length + 1].X = 0;
            //lux3DPoint[length + 1].Y = 0;
            //lux3DPoint[length + 1].Z = 0;
            //Chart3DPointSeries lux3DPointSeries = new Chart3DPointSeries();

            //axisX1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX1Point[0].X = 0;
            axisX1Point[0].Y = 0;
            axisX1Point[0].Z = 0;
            axisX1Point[1].X = max / 2;
            axisX1Point[1].Y = 0;
            axisX1Point[1].Z = 0;

            //axisX1Series = new Chart3DPointSeries();
            axisX1Series.Points = axisX1Point;

            //axisX2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX2Point[0].X = max / 2;
            axisX2Point[0].Y = line;
            axisX2Point[0].Z = 0;
            axisX2Point[1].X = max / 2;
            axisX2Point[1].Y = 0;
            axisX2Point[1].Z = 0;
            //axisX2Series = new Chart3DPointSeries();
            axisX2Series.Points = axisX2Point;

            //axisX3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisX3Point[0].X = max / 2 - line;
            axisX3Point[0].Y = -line;
            axisX3Point[0].Z = 0;
            axisX3Point[1].X = max / 2;
            axisX3Point[1].Y = 0;
            axisX3Point[1].Z = 0;
            //axisX3Series = new Chart3DPointSeries();
            axisX3Series.Points = axisX3Point;

            dataSetPoint.SeriesCollection.Add(axisX1Series);
            dataSetPoint.SeriesCollection.Add(axisX2Series);
            dataSetPoint.SeriesCollection.Add(axisX3Series);

            dataSetPoint.SeriesCollection[0].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[0].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[0].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[0].Connected = true;
            dataSetPoint.SeriesCollection[0].Style.SymbolStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[1].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[1].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[1].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[1].Connected = true;
            dataSetPoint.SeriesCollection[1].Style.SymbolStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[2].Style.LineStyle.Color = Color.Red;
            dataSetPoint.SeriesCollection[2].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[2].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[2].Connected = true;
            dataSetPoint.SeriesCollection[2].Style.SymbolStyle.Color = Color.Red;



            //axisY1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY1Point[0].X = 0;
            axisY1Point[0].Y = 0;
            axisY1Point[0].Z = 0;
            axisY1Point[1].X = 0;
            axisY1Point[1].Y = max / 2;
            axisY1Point[1].Z = 0;

            //axisY1Series = new Chart3DPointSeries();
            axisY1Series.Points = axisY1Point;

            //axisY2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY2Point[0].X = line;
            axisY2Point[0].Y = max / 2 - line;
            axisY2Point[0].Z = 0;
            axisY2Point[1].X = 0;
            axisY2Point[1].Y = max / 2;
            axisY2Point[1].Z = 0;
            //axisY2Series = new Chart3DPointSeries();
            axisY2Series.Points = axisY2Point;

            //axisY3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisY3Point[0].X = -line;
            axisY3Point[0].Y = max / 2 - line;
            axisY3Point[0].Z = 0;
            axisY3Point[1].X = 0;
            axisY3Point[1].Y = max / 2;
            axisY3Point[1].Z = 0;
            //axisY3Series = new Chart3DPointSeries();
            axisY3Series.Points = axisY3Point;


            dataSetPoint.SeriesCollection.Add(axisY1Series);
            dataSetPoint.SeriesCollection.Add(axisY2Series);
            dataSetPoint.SeriesCollection.Add(axisY3Series);

            dataSetPoint.SeriesCollection[3].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[3].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[3].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[3].Connected = true;
            dataSetPoint.SeriesCollection[3].Style.SymbolStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[4].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[4].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[4].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[4].Connected = true;
            dataSetPoint.SeriesCollection[4].Style.SymbolStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[5].Style.LineStyle.Color = Color.Green;
            dataSetPoint.SeriesCollection[5].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[5].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[5].Connected = true;
            dataSetPoint.SeriesCollection[5].Style.SymbolStyle.Color = Color.Green;


            //axisZ1Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ1Point[0].X = 0;
            axisZ1Point[0].Y = 0;
            axisZ1Point[0].Z = 0;
            axisZ1Point[1].X = 0;
            axisZ1Point[1].Y = 0;
            axisZ1Point[1].Z = max;

            //axisZ1Series = new Chart3DPointSeries();
            axisZ1Series.Points = axisZ1Point;

            //axisZ2Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ2Point[0].X = line;
            axisZ2Point[0].Y = 0;
            axisZ2Point[0].Z = max - line;
            axisZ2Point[1].X = 0;
            axisZ2Point[1].Y = 0;
            axisZ2Point[1].Z = max;
            //axisZ2Series = new Chart3DPointSeries();
            axisZ2Series.Points = axisZ2Point;

            //axisZ3Point = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 2);
            axisZ3Point[0].X = -line;
            axisZ3Point[0].Y = 0;
            axisZ3Point[0].Z = max - line;
            axisZ3Point[1].X = 0;
            axisZ3Point[1].Y = 0;
            axisZ3Point[1].Z = max;
            //axisZ3Series = new Chart3DPointSeries();
            axisZ3Series.Points = axisZ3Point;

            dataSetPoint.SeriesCollection.Add(axisZ1Series);
            dataSetPoint.SeriesCollection.Add(axisZ2Series);
            dataSetPoint.SeriesCollection.Add(axisZ3Series);

            dataSetPoint.SeriesCollection[6].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[6].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[6].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[6].Connected = true;
            dataSetPoint.SeriesCollection[6].Style.SymbolStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[7].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[7].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[7].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[7].Connected = true;
            dataSetPoint.SeriesCollection[7].Style.SymbolStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[8].Style.LineStyle.Color = Color.Blue;
            dataSetPoint.SeriesCollection[8].Style.SymbolStyle.Shape = SymbolShapeEnum.None;
            dataSetPoint.SeriesCollection[8].Style.LineStyle.Thickness = 1;
            dataSetPoint.SeriesCollection[8].Connected = true;
            dataSetPoint.SeriesCollection[8].Style.SymbolStyle.Color = Color.Blue;

            this.chart3D.ChartArea.AxisX.AutoMajor = true;
            this.chart3D.ChartArea.AxisX.AutoMinor = true;
            this.chart3D.ChartArea.AxisX.Min = -max;
            this.chart3D.ChartArea.AxisX.Max = max;
            this.chart3D.ChartArea.AxisY.AutoMajor = true;
            this.chart3D.ChartArea.AxisY.AutoMinor = true;
            this.chart3D.ChartArea.AxisY.Min = -max;
            this.chart3D.ChartArea.AxisY.Max = max;
            this.chart3D.ChartArea.AxisZ.AutoMajor = true;
            this.chart3D.ChartArea.AxisZ.AutoMinor = true;
            this.chart3D.ChartArea.AxisZ.Min = 0;
            this.chart3D.ChartArea.AxisZ.Max = max;


            dataSetPoint.SeriesCollection[(int)thetaDegree / 15 + 9].Points = lux3DPoint;
            dataSetPoint.SeriesCollection[(int)thetaDegree / 15 + 9].Style.LineStyle.Color = lineColor[(int)thetaDegree / 15];
        }

        public void Clear()
        {
            Chart3DPoint[] pot = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot1 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot2 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot3 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot4 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot5 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot6 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot7 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot8 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot9 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot10 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            Chart3DPoint[] pot11 = (Chart3DPoint[])Array.CreateInstance(typeof(Chart3DPoint), 1);
            pot[0] = new Chart3DPoint(0, 0, 0);
            pot1[0] = new Chart3DPoint(0, 0, 0);
            pot2[0] = new Chart3DPoint(0, 0, 0);
            pot3[0] = new Chart3DPoint(0, 0, 0);
            pot4[0] = new Chart3DPoint(0, 0, 0);
            pot5[0] = new Chart3DPoint(0, 0, 0);
            pot6[0] = new Chart3DPoint(0, 0, 0);
            pot7[0] = new Chart3DPoint(0, 0, 0);
            pot8[0] = new Chart3DPoint(0, 0, 0);
            pot9[0] = new Chart3DPoint(0, 0, 0);
            pot10[0] = new Chart3DPoint(0, 0, 0);
            pot11[0] = new Chart3DPoint(0, 0, 0);

            dataSetPoint.SeriesCollection[9].Points = pot;
            dataSetPoint.SeriesCollection[10].Points = pot1;
            dataSetPoint.SeriesCollection[11].Points = pot2;
            dataSetPoint.SeriesCollection[12].Points = pot3;
            dataSetPoint.SeriesCollection[13].Points = pot4;
            dataSetPoint.SeriesCollection[14].Points = pot5;
            dataSetPoint.SeriesCollection[15].Points = pot6;
            dataSetPoint.SeriesCollection[16].Points = pot7;
            dataSetPoint.SeriesCollection[17].Points = pot8;
            dataSetPoint.SeriesCollection[18].Points = pot9;
            dataSetPoint.SeriesCollection[19].Points = pot10;
            dataSetPoint.SeriesCollection[20].Points = pot11;
        }

        #endregion

        #region 窗体事件

        private void frmL3_Load(object sender, EventArgs e)
        {
            initialize();
        }

        private void frmL3_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();
            e.Cancel = true;// 取消关闭事件
        }

        #endregion
    }
}
